package com.gewu.pm.ui.activity.clockin;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.viewpager.widget.ViewPager;

import com.androidkun.xtablayout.XTabLayout;
import com.gewu.pm.R;
import com.gewu.pm.app.AppActivity;
import com.gewu.pm.app.AppFragment;
import com.gewu.pm.ui.fragment.clockin.MyClockInFragment;
import com.gewu.pm.ui.fragment.clockin.SubordinateClockInFragment;
import com.hjq.bar.TitleBar;
import com.hjq.base.FragmentPagerAdapter;

/**
 * 打卡记录Activity
 */
public final class ClockInRecordActivity extends AppActivity {

    private TitleBar mTitleBar;
    private XTabLayout mTabLayout;
    private ViewPager mViewPager;
    private FragmentPagerAdapter<AppFragment<?>> mPagerAdapter;

    public static void start(Context context) {
        Intent intent = new Intent(context, ClockInRecordActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.clock_in_record_activity;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mTitleBar = findViewById(R.id.tb_title);
        mTabLayout = findViewById(R.id.xtl_tabs);
        mViewPager = findViewById(R.id.vp_content);

        setupViewPager();
    }

    @Override
    protected void initData() {
        // 加载数据
    }

    /**
     * 设置ViewPager
     */
    private void setupViewPager() {
        mPagerAdapter = new FragmentPagerAdapter<>(this);
        mPagerAdapter.addFragment(MyClockInFragment.newInstance(), getString(R.string.my_attendance));
        mPagerAdapter.addFragment(SubordinateClockInFragment.newInstance(), getString(R.string.subordinate_attendance));
        mViewPager.setAdapter(mPagerAdapter);
        
        // 关联XTabLayout和ViewPager
        mTabLayout.setupWithViewPager(mViewPager);
    }
}
